# 导包
import time

from selenium import webdriver
# 实例化浏览器驱动
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome()
driver.maximize_window()
# 打开测试网站
driver.get("http://192.168.0.108/Home/user/login.html")
print("开始时间：", time.strftime("%H:%M:%S"))
# 通过显示等待的方式定位延时输入框输入admin
element = WebDriverWait(driver, 10, 1).until(lambda x: x.find_element(By.ID, "username"))
print("第一个元素定位的时间：", time.strftime("%H:%M:%S"))
element.send_keys("13125056588")
element = WebDriverWait(driver, 5, 1).until(lambda x: x.find_element(By.ID, "password"))
print("第二个元素定位的时间：", time.strftime("%H:%M:%S"))
element.send_keys("Dd112211")
# 等待3S
time.sleep(3)
# 退出浏览器驱动
driver.quit()
